{include file='_header'}
<script type="text/javascript" src="/public/static/js/dist/area/cascade1.js"></script>
<style>
    .checkbox-inline{
        display: block;
    }    .btns a i{
        display: inline-block;
        width: 100%;
        height: 20px;
        background: #f95959;
    }
    .btn-color {
        width: 25px;
        height: 25px;
        border: 1px solid #fff;
        margin: 2px;
        padding: 0;
    }

</style>
<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}门店
        <small>{if !empty($item['id'])}修改【{$item['storename']}】{/if}</small>
    </span>
</div>

<div class="page-content">
    <div class="page-sub-toolbar">
        <a class="btn btn-primary btn-sm" href="{:url('admin/merch/storeadd')}">添加新门店</a>
    </div>
<form action="" method="post" class="form-horizontal form-validate" enctype="multipart/form-data">
    <input type="hidden" name="id" value="{$item['id']}"/>

    <div class="form-group">
        <label class="col-lg control-label must">门店名称</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="storename" class="form-control" value="{$item['storename']}" data-rule-required="true"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label must">门店LOGO</label>
        <div class="col-sm-9 col-xs-12">
            {:tpl_form_field_image2('logo',$item['logo'])}
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label must">省市区 :</label>
        <div class="col-sm-9 col-xs-12">
            <p>
                <select id="sel-provance" name="province" onChange="selectCity();" class="select form-control select-group" style="width:123px;display:inline;">
                    <option value="" selected="true">省/直辖市</option>
                </select>
                <select id="sel-city" name="city" onChange="selectcounty(0)" class="select form-control select-group" style="width:135px;display:inline;">
                    <option value="" selected="true">请选择</option>
                </select>
                <select id="sel-area" name="area" onChange="selectstreet(0)" class="select form-control select-group" style="width:130px;display:inline;">
                    <option value="" selected="true">请选择</option>
                </select>
                {if !empty($new_area) && !empty($address_street)}
                <select id="sel-street" name="street" class="select form-control select-group" style="width:220px;display:none;margin-top: 10px;">
                    <option value="" selected="true">请选择</option>
                </select>
                {/if}
            </p>

            <input type="hidden" name="chose_province_code" id="chose_province_code" value="{$item['provincecode']}" />
            <input type="hidden" name="chose_city_code" id="chose_city_code" value="{$item['citycode']}" />
            <input type="hidden" name="chose_area_code" id="chose_area_code" value="{$item['areacode']}" />
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg control-label must">门店电话</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="tel" class="form-control" value="{$item['tel']}" data-rule-required="true"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">营业时间</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="saletime" class="form-control" value="{$item['saletime']}"/>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label must">门店位置</label>
        <div class="col-sm-9 col-xs-12">
            {:tpl_form_field_position('map',array('lng'=>$item['lng'],'lat'=>$item['lat']))}
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg control-label must">门店地址</label>
        <div class="col-sm-9 col-xs-12">
            <input type="text" name="address" class="form-control" value="{$item['address']}" data-rule-required="true"/>
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg control-label">门店支持</label>
        <div class="col-sm-9 col-xs-12">
            <label class='radio-inline'>
                <input type='radio' name='type' value='1' {if $item['type']==1}checked{/if} /> 支持自提
            </label>

            <label class='radio-inline'>
                <input type='radio' name='type' value='2' {if $item['type']==2}checked{/if} /> 支持核销
            </label>

            <label class='radio-inline'>
                <input type='radio' name='type' value='3' {if $item['type']==3}checked{/if} /> 支持自提+核销
            </label>

            <label class='radio-inline'>
                <input type='radio' name='type' value='0' {if $item['type']==0}checked{/if} /> 全都不支持
            </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">联系人信息</label>
        <div class="col-sm-10 col-xs-12">
            <label class="radio-inline" style="float: left;padding-left:0px;">姓名</label>
            <div class="col-sm-9 col-xs-12" style="width: 120px; float: left; margin: 0px 20px 0px -5px;">
                <input type="text" value="{$item['realname']}" class="form-control" name="realname" style="width:120px;padding:5px;">
            </div>
            <label class="radio-inline" style="float: left;">电话</label>
            <div class="col-sm-9 col-xs-12" style="width: 120px; float: left; margin: 0px 20px 0px -5px;">
                <input type="text" value="{$item['mobile']}" class="form-control" name="mobile" style="width:120px;padding:5px;">
            </div>
        </div>
    </div>
    <div class="form-group">
        <label class="col-lg control-label">门店简介</label>
        <div class="col-sm-9 col-xs-12">
            <textarea name="desc" class="form-control richtext" rows="5">{$item['desc']}</textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg control-label must">权限管理</label>
        <div class="col-sm-9 col-xs-12">
            <div class="col-sm-10">
                <label class="checkbox-inline" >
                    <input type="checkbox" name="perms[]" value="storeinfo" {if in_array('storeinfo',$perms)} checked{/if}>  门店基本信息编辑</label>
                <label class="checkbox-inline"  >
                    <input type="checkbox" name="perms[]" value="saler" {if in_array('saler',$perms)} checked{/if}>  店员管理</label>
           <!--     <label class="checkbox-inline">
                    <input type="checkbox" name="perms[]" value="sale" {if in_array('sale',$perms)} checked{/if}>  营销管理</label>-->
                <label class="checkbox-inline">
                    <input type="checkbox" name="perms[]" value="stock"  {if in_array('stock',$perms)} checked{/if}>  商品库存管理</label>
                <label class="checkbox-inline">
                    <input type="checkbox" name="perms[]" value="delete" {if in_array('delete',$perms)} checked{/if} >  商品上架下架</label>
                <label class="checkbox-inline">
                    <input type="checkbox" name="perms[]" value="norder" {if in_array('norder',$perms)} checked{/if}>  预约商品管理</label>
            </div>
        </div>
    </div>

    <div class="form-group">
        <label class="col-lg control-label">状态</label>
        <div class="col-sm-9 col-xs-12">
            <label class='radio-inline'>
                <input type='radio' name='status' value=1' {if $item['status']==1}checked{/if} /> 启用
            </label>
            <label class='radio-inline'>
                <input type='radio' name='status' value=0' {if $item['status']==0}checked{/if} /> 禁用
            </label>
        </div>
    </div>
    <div class="form-group"></div>
    <div class="form-group">
        <label class="col-lg control-label"></label>
        <div class="col-sm-9 col-xs-12">
            <input type="submit" value="提交" class="btn btn-primary"/>
            <input type="button" name="back" onclick='history.back()' {ifp  'store.add|store.edit'}style='margin-left:10px;'{/if} value="返回列表" class="btn btn-default" />
        </div>
    </div>
</form>
</div>
<script language='javascript'>
    $(function () {
        $(':radio[name=type]').click(function () {
            type = $("input[name='type']:checked").val();

            if (type == '1' || type == '3') {
                $('#pick_info').show();
            } else {
                $('#pick_info').hide();
            }
        })
    })

    //添加标签
    function addLabelItem(){
        if($('.label-items')[0].childElementCount<8)
        {
            var html= '<div class="input-group recharge-item"  style="width:300px;margin-top:5px">';
            html+='<span class="input-group-addon">内容</span>';
            html+='<input type="text" class="form-control"  style="width:200px;" maxlength="20" name="lab[]"  />';
            html+='<div class="input-group-btn"><button class="btn btn-danger" type="button" onclick="removeLabelItem(this)"><i class="fa fa-remove"></i></button></div></div>';

            $('.label-items').append(html);
        }else{
            tip.msgbox.err("标签最多八个!");
        }
    }

    //添加角标
    function addTagItem(){
        if($('.tag-items')[0].childElementCount<3)
        {
            var html= '<div class="input-group recharge-item"  style="width:300px;margin-top:5px">';
            html+='<span class="input-group-addon">内容</span>';
            html+='<input type="text" class="form-control"  style="width:200px;" maxlength="3" name="tag[]"  />';
            html+='<div class="input-group-btn"><button class="btn btn-danger" type="button" onclick="removeTagItem(this)"><i class="fa fa-remove"></i></button></div></div>';

            $('.tag-items').append(html);
        }else{
            tip.msgbox.err("角标最多三个!");
        }
    }

    //删除标签
    function removeLabelItem(obj){
        $(obj).closest('.recharge-item').remove();
    }
    //删除角标
    function removeTagItem(obj){
        $(obj).closest('.recharge-item').remove();
    }

    cascdeInit1("{$new_area}","{$address_street}","{:isset($item['province'])?$item['province']:''}","{:isset($item['city'])?$item['city']:''}","{:isset($item['area'])?$item['area']:''}","''");
</script>
{include file='_footer'}